<%@ Page Language="C#" MasterPageFile="~/Admin.master" AutoEventWireup="true" CodeFile="ModifyCharges.aspx.cs" Inherits="Pages_Admin_ModifyCharges" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:Label ID="Label1" runat="server" Font-Bold="True" Text="Modify charges" CssClass="header"></asp:Label>
<br />
<br />
    <asp:DropDownList ID="ddlService" runat="server" DataSourceID="ServicesDataSource"
        DataTextField="ServiceName" DataValueField="ServiceID">
    </asp:DropDownList>
    &nbsp;
    <asp:DropDownList ID="ddlDistance" runat="server" DataSourceID="DistanceDataSource"
        DataTextField="Description" DataValueField="DistanceID">
    </asp:DropDownList>&nbsp;
    <asp:Button ID="btnView" runat="server" Text="View" OnClick="btnView_Click" />
    <asp:SqlDataSource ID="DistanceDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:TarsConnection %>"
        SelectCommand="SELECT [DistanceID], [Description] FROM [Distance]"></asp:SqlDataSource>
    <asp:SqlDataSource ID="ServicesDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:TarsConnection %>"
        SelectCommand="SELECT [ServiceID], [ServiceName] FROM [Services]"></asp:SqlDataSource>
    <br />
    <br />
    <asp:Label ID="lblMessage" runat="server" />
    <asp:ValidationSummary ID="ValidationSummary1" runat="server"/>
    <br />
    <br />
    <asp:GridView ID="gvPriceTable" runat="server" AutoGenerateColumns="False" DataSourceID="ServicePriceDataSource" HeaderStyle-CssClass="smallheader" HeaderStyle-BackColor="#a9c0f2" BorderColor="#556CB0" GridLines="Vertical" Width="320px" OnRowUpdating="gvPriceTable_RowUpdating" OnRowEditing="gvPriceTable_RowEditing">
        <Columns>
            <asp:BoundField DataField="Description" HeaderText="Weight" ReadOnly="True" SortExpression="Description" />
            <asp:TemplateField HeaderText="Price" SortExpression="Price">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Price") %>' Width="93px"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1"
                        ErrorMessage="Price cannot be blank">*</asp:RequiredFieldValidator>
                    <asp:CustomValidator ID="CustomValidator1" runat="server" ControlToValidate="TextBox1"
                        ErrorMessage="Price must be a positive decimal number" OnServerValidate="CustomValidator1_ServerValidate">*</asp:CustomValidator>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("Price") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:CommandField ShowEditButton="True" />
        </Columns>
        <HeaderStyle HorizontalAlign="Center" BackColor="#A9C0F2" CssClass="smallheader" />
        <AlternatingRowStyle BackColor="Gainsboro" />
        <RowStyle HorizontalAlign="Center" />
    </asp:GridView>
    <asp:SqlDataSource ID="ServicePriceDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:TarsConnection %>"
        SelectCommand="SELECT Weight.Description, ServicePrice.Price FROM ServicePrice INNER JOIN Weight ON ServicePrice.WeightID = Weight.WeightID WHERE (ServicePrice.ServiceID = @ServiceID) AND (ServicePrice.DistanceID = @DistanceID)">
        <SelectParameters>
            <asp:ControlParameter ControlID="ddlService" Name="ServiceID" PropertyName="SelectedValue" />
            <asp:ControlParameter ControlID="ddlDistance" Name="DistanceID" PropertyName="SelectedValue" />
        </SelectParameters>
    </asp:SqlDataSource>
</asp:Content>

